package com.ln.asset.core.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ln.asset.core.mapper.MaintainMapper;
import com.ln.asset.core.pojo.Maintain;
import com.ln.asset.core.service.MaintainService;
import com.ln.asset.core.utils.LendNoUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 维修表 服务实现类
 * </p>
 *
 * @author jijiaqi
 * @since 2022-05-02
 */
@Service
public class MaintainServiceImpl extends ServiceImpl<MaintainMapper, Maintain> implements MaintainService {
@Resource
private MaintainMapper maintainMapper;

    @Override
    public IPage<Maintain> getMainListPage(Page<Maintain> objectPage) {
        Page<Maintain> pages = baseMapper.selectPage(objectPage, null);
        return pages;
    }

    @Override
    public void insertMain(Maintain maintain) {
        maintain.setOdd(LendNoUtils.getLendNo());
        maintain.setIsDeleted(0);
        baseMapper.insert(maintain);
    }

    @Override
    public void updateMainStatus(Integer status, Maintain maintain) {
        if(status==1){
            maintain.setMstate(1);
            baseMapper.updateById(maintain);
        }else if(status==2){
            maintain.setMstate(2);
            baseMapper.updateById(maintain);
        }
    }

    @Override
    public void delMain(Integer id) {

        maintainMapper.deleteById(id);


    }

    @Override
    public Map<String, Object> selectDetails(Integer id) {
        return null;
    }

//    @Override
//    public Map<String, Object> selectDetails(Integer id) {
//        Maintain maintain = baseMapper.selectById(id);
//
//       List<MaintainVo> maintainVo = maintainMapper.selectAssetByTransid(id);
//
//        Map<String,Object> map = new HashMap<>();
//        map.put("transformation",maintain);
//        map.put("transforDetailsVO",maintainVo);
//
//        return map;
//    }
}
